#include<stdio.h>
struct student
{
	int score;
	char name[10];
};

int main()
{
	int t,num,i=0,fail=0;//fail不及格人数
	int D=0,C=0,B=0,A=0;//j为60-79的人数
	/*
	   g为90-100的人数
	   m为70-80的人数
	   h为80-90的人数
	   */
	struct student stu[30];//定义30个结构体
	void print(int);
	do{
		printf("输入人数:");
		scanf("%d",&num);
	}while(num>30);
	t=num;
	while(num--)
	{
		printf("输入名字:");
		scanf("%s",&stu[i].name);
		printf("输入成绩:");
		scanf("%d",&stu[i].score);
		if(stu[i].score<0||stu[i].score>100){num++;continue;}
		if(stu[i].score<60)fail++;
		if(stu[i].score>=60&&stu[i].score<70)D++;
		if(stu[i].score>=70&&stu[i].score<80)C++;
		if(stu[i].score>=80&&stu[i].score<90)B++;
		if(stu[i].score>=90&&stu[i].score<=100)A++;
		i++;
	}
	printf("不及格人数:%d\n",fail);
	printf("不及格名单:\n");
	for(i=0;i<t;i++){
		if(stu[i].score<60)printf("%s\n",stu[i].name);//输出不及格的名单
	}
	printf("------------------------------------------\n");
	printf("| 分数段  | 学生人数       | 图形\n");
	printf("------------------------------------------\n");
	printf("| <60     | %d(%06.2lf%%)%-2s   | ",fail,(fail*1.0)/(t*1.0)*100," ");	
	print(fail);
	printf("------------------------------------------\n");
	printf("| 60-69   | %d(%06.2lf%%)%-2s   | ",j,(j*1.0)/(t*1.0)*100," ");
	print(D);
	printf("------------------------------------------\n");
	printf("| 70-79   | %d(%06.2lf%%)%-2s   | ",m,(m*1.0)/(t*1.0)*100," ");	
	print(C);
	printf("------------------------------------------\n");
	printf("| 80-89   | %d(%06.2lf%%)%-2s   | ",h,(h*1.0)/(t*1.0)*100," ");	
	print(B);
	printf("------------------------------------------\n");
	printf("| 90-100  | %d(%06.2lf%%)%-2s   | ",g,(g*1.0)/(t*1.0)*100," ");	
	print(A);
	printf("------------------------------------------\n");
}

void print(int n)//显示直方图
{
	while(n--)
		printf("*");
	printf("\n");
}
